package org.gradle.springboot.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.gradle.springboot.bean.Student;
import org.gradle.springboot.services.UserService;
import org.gradle.springboot.view.excel.HomePage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;


@Controller
@RequestMapping("/user")
@Api(value="用户管理")
public class UserController {
	
	@Autowired
	private UserService userService;

	@ApiOperation(value="获取用户列表", notes="get user list")
	@RequestMapping("/userInfo")
	public String loadUserInfo(Map<String, Object> map) {
		List<Student> students = new ArrayList<>();
		students.add(new Student("cjw", 28));
		students.add(new Student("fat", 27));
		Object obj = userService.getAllUsers();
		map.put("users", obj);
		return "user/userInfo";
	}
	
	@ApiOperation(value="根据用户ID获取用户信息", notes="根据用户ID获取用户信息")
	@ResponseBody
	@RequestMapping("loadUserDetail")
	public Student loadStudent(String id) {
		return userService.loadStudent(id);
	}
	
	@RequestMapping("/countDown")
	public String countDownView() {
		return "util/countDown";
	}
	
	@RequestMapping("/export")
	public ModelAndView exportExcel() {
		return new ModelAndView(new HomePage());
	}
	
}
